/*
 ============================================================================
 Name		: StringUtil.h
 Author	  : lin.chaoming
 Version	 : 0.1
 Copyright   : do1
 Description : CStringUtil declaration
 ============================================================================
 */

#ifndef STRINGUTIL_H
#define STRINGUTIL_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <badesca.h>
#include <EscapeUtils.h>

class CStringUtil
{
public:
    static HBufC* TransformCharToHBufC(const char* src);
    static char* TransformTDes8ToChar(const TDesC8 &src);
    static const char* TransformTDes8ToConstChar(const TDesC8 &src);
    static const char* TransformHBufToConstChar(HBufC8 *src);
    static  HBufC8* TransformHBufCToHBufC8( HBufC *src);
    static  HBufC* TransformHBufC8ToHBufC( HBufC8 *src);
    static  HBufC8* TransformTDesCToHBufC8( const TDesC &src);
    static const char* TransformTDesToConstChar(const TDesC &src);
    static  HBufC8* TransformCharToHBufC8(const char* src);
    
    static TBool TDesC2TInt(const TDesC& aDesC,TInt& aInt);
    static HBufC8* Base64EncodeLC(const TDesC8 & aSourceBuf);
    static HBufC8* Base64DecodeLC(const TDesC8 & aSourceBuf);
    
    static HBufC* ReplaceL(const TDesC& aSrc,const TDesC& aSrcSub, const TDesC& aReplacement=KNullDesC);
    static void SpliteL(CDesCArray& aDesCArray,const TDesC& aDesCSrc,const TDesC& aSpliteDesC);

    static HBufC8* ConvertFromUnicodeToUtf8L(const TDesC&  aData);
    static HBufC*  ConvertToUnicodeFromUtf8L(const TDesC8& aData);
    static void GetApplicationLocate(TDes &locateBuf);
    
    static HBufC* Gbk2UniL( const TDesC8& aGbkDes);
    static TInt ConvGbk2UniL( const TDesC8& aGbkDes, TDes& aUniDes);
    static TInt ConvUni2GbkL( const TDesC& aUniDes, TDes8& aGbkDes);
    static HBufC8* ConvUni2GbkL( const TDesC& aUniDes);
    
    static HBufC* DeleteFilter( const TDesC& aAllDesc, const TDesC& aFilter);
    static HBufC* DeleteTaobaoFilter( const TDesC& aAllDesc);
    
    static HBufC16* EscapeEncodeL(const TDesC16& aData, EscapeUtils::TEscapeMode aMode = EscapeUtils::EEscapeNormal);
    static HBufC16* EscapeDecodeL(const TDesC16& aData);
    static HBufC* TransFormHtmlCode(const TDesC& aAllDesc);
};

#endif // STRINGUTIL_H
